package ru.vsu.amm.io;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * 
 * @author Иванов Илья
 * @since 23 января 2013
 *
 */
public class CommonIO {
	
	public static <T> String readResourceAsString(Class<T> classLoaderType, String resourceName) {
		try (BufferedReader reader = new BufferedReader(new InputStreamReader(classLoaderType.getResourceAsStream(resourceName), "UTF-8"))) {
			StringBuffer resourceString = new StringBuffer();
			String line;
			while ((line = reader.readLine()) != null)
				resourceString.append(line);
			
			return resourceString.toString();
		} catch (Exception e) {
			return null;
		}
	}
}